import time

from selenium import webdriver

'''basePage对象，主要用于各类常规的操作行为，便于页面对象进行调用'''


class BasePage:
    # 创建一个driver对象
    # driver = webdriver.Chrome()
    url = 'http://39.98.138.157/shopxo/index.php'

    def __init__(self, driver):
        self.driver = driver

    # 访问url
    def visit(self):
        self.driver.get(self.url)

    # 元素定位
    def locator(self, loc):
        return self.driver.find_element(*loc)

    # 元素的输入行为
    def input_(self, loc, txt):
        self.locator(loc).send_keys(txt)

    # 元素的点击行为
    def click(self, loc):
        self.locator(loc).click()

    def quit(self):
        self.driver.quit()

    def sleep(self):
        time.sleep(5)
